using System.Collections;
using System.Collections.Generic;
using System.Linq;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

public class MapSceneUI : MonoBehaviour
{


    // MapScene========================================
    public void OnStart()
    {
        Setup();
        MapSystem.Instance.Setup();
        MapSystem.Instance.ShowMap();
        // StartCoroutine(LoadScene("FightScene"));
        // OnFightSceneSave();
    }

    public void OnContinue()
    {
        InfoSystem.Instance.LoadGame();
        MapSystem.Instance.Setup();
        MapSystem.Instance.ShowMap();
        // StartCoroutine(LoadScene("FightScene"));
        // OnFightSceneSave();
    }

    // 未来指定初始英雄
    public void Setup()
    {
        Hero1 hero = new Hero1();
        // 确保使用改进后的Hero1初始化方法
        (hero as Hero1).InitializeNewHero();
        InfoSystem.Instance.hero = hero;
        InfoSystem.Instance.ResetInfo();
        InfoSystem.Instance.SaveGame();
    }

    private IEnumerator LoadScene(string sceneName)
    {
        AsyncOperation asyncLoad = SceneManager.LoadSceneAsync(sceneName);
        while (!asyncLoad.isDone)
        {
            yield return null; // 等待下一帧继续检查
        }
    }
    public void OnGoFireScene()
    {
        InfoSystem.Instance.LoadGame();
        StartCoroutine(LoadScene("FireScene"));
    }


    public void OnGoStore()
    {
        StoreSystem.Instance.Setup();
    }



}
